package main

import (
	"context"
	"fmt"
	"go-web-learning/src/05_grpc/2_hello_world/proto_go"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"google.golang.org/grpc/grpclog"
)

func main() {
	addr := ":8080"
	conn, err := grpc.Dial(addr,
		grpc.WithTransportCredentials(insecure.NewCredentials()),
	)
	if err != nil {
		grpclog.Fatalf("Dial server [%s] failed: %s", addr, err.Error())
	}
	defer conn.Close()
	// 初始化客户端
	client := proto_go.NewHelloServiceClient(conn)
	result, err := client.SayHello(context.Background(), &proto_go.HelloRequest{Name: "talon", Message: "2"})
	fmt.Println(result)
}
